<?php
/**
* phpCan - http://idc.anavallasuiza.com/
*
* phpCan is released under the GNU Affero GPL version 3
*
* More information at license.txt
*/

defined('ANS') or die();

$Config->load('languages.php', 'scene', 'scene_');

$language = $Vars->get('download_language');
$file = str_replace(array('..', '/', '\\'), '', $Vars->get('download_file'));

if (!in_array($language, $Config->scene_languages['availables'])) {
	$Vars->message(__('No valid language was selected.'), 'ko');

	return false;
} else if (!is_file(filePath('scene/languages|'.$language.'/'.$file.'.po'))) {
	$Vars->message(__('Language file doesn\'t exists.'), 'ko');

	return false;
}

$contents = file_get_contents(filePath('scene/languages|'.$language.'/'.$file.'.po'));

header('Pragma: private');
header('Expires: 0');
header('Cache-control: private, must-revalidate');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Content-Type: text/csv; charset=UTF-8');
header('Content-Type: application/force-download');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="'.$language.'.po"');
header('Content-Length: '.strlen($contents));

echo $contents;

exit;
?>
